#include <iostream>
using namespace std;


void selve(int n,int m)
{
    int t,j;
    int sun=1;
    for(t=n*2,j=n*2+1;t<=m;t=t*2,j=j*2+1,sun*=2);
    if(m>(j-1)/2)
        m=(j-1)/2;
    sun+=m-t/2;
    cout<<sun<<endl;
}



int main() {
    int n,m;
    while(cin>>n>>m&&n!=0&&m!=0)
    {
        selve(n,m);
    }
    return 0;
}
